package com.lb.jwitter.action;


import java.util.List;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import com.lb.jwitter.util.ApplicationContextProvider; 
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; 
import org.springframework.test.context.ContextConfiguration;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.lb.jwitter.service.ConditionReport; 
 import java.util.Map; 
import com.opensymphony.xwork2.ActionContext; 
import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.TblQLDTTXADonXinGiaHanHPChiTiet;
import com.lb.jwitter.service.TblQLDTTXADonXinGiaHanHPChiTietService;
import com.lb.jwitter.service.TblQuyenChiTietService;import com.lb.jwitter.service.TblTaiKhoan;import com.lb.jwitter.service.TblQLDTTXADonXinGiaHanHocPhi;
import com.lb.jwitter.service.TblQLDTTXADonXinGiaHanHocPhiService;
import com.lb.jwitter.service.TblQLDTTXAHocVien;
import com.lb.jwitter.service.TblQLDTTXAHocVienService;

import com.lb.jwitter.service.TblCanBo;
import com.lb.jwitter.service.TblCanBoService;

import com.lb.jwitter.service.TblQLDTTXAHocKyTrongNam;
import com.lb.jwitter.service.TblQLDTTXAHocKyTrongNamService;

import com.lb.jwitter.service.TblQLDTTXAHocKyTrongNam;
import com.lb.jwitter.service.TblQLDTTXAHocKyTrongNamService;

import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhiMonHoc;
import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhiMonHocService;

import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhi;
import com.lb.jwitter.service.TblQLDTTXAHocVienHocPhiService;

import com.lb.jwitter.service.TblQLDTTXAMonHoc;
import com.lb.jwitter.service.TblQLDTTXAMonHocService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblQLDTTXADonXinGiaHanHocPhiEditFormAction{
    private int pageSize; 
    public int getPageSize() {
       return pageSize;
 }

    public void setPageSize(int pageSize) { this.pageSize = pageSize; }

    private int page; 
    public int getPage() { return page; }

    public void setPage(int page) { this.page = page; }

    private int pages; 
    public int getPages() { return pages; }

    public void setPages(int pages) { this.pages = pages; }

    private int id; 
    public void setId(int id) { this.id = id; }

    public int getId() { return id; }

    private TblQLDTTXADonXinGiaHanHocPhi tblQLDTTXADonXinGiaHanHocPhi; 
    public TblQLDTTXADonXinGiaHanHocPhi getTblQLDTTXADonXinGiaHanHocPhi() { 
        return tblQLDTTXADonXinGiaHanHocPhi; 
    } 
    private List<TblQLDTTXADonXinGiaHanHocPhi> tblQLDTTXADonXinGiaHanHocPhis; 
    public List<TblQLDTTXADonXinGiaHanHocPhi>  getTblQLDTTXADonXinGiaHanHocPhis() {
         return tblQLDTTXADonXinGiaHanHocPhis; 
      } 

    private TblQLDTTXADonXinGiaHanHocPhiService tblQLDTTXADonXinGiaHanHocPhiService; 

    private List<TblQLDTTXAHocVien> tblQLDTTXAHocViens; 
    public List<TblQLDTTXAHocVien>  getTblQLDTTXAHocViens(){ 
              return tblQLDTTXAHocViens; 
     } 

    private TblQLDTTXAHocVienService tblQLDTTXAHocVienService; 

    private List<TblCanBo> tblCanBos; 
    public List<TblCanBo>  getTblCanBos(){ 
              return tblCanBos; 
     } 

    private TblCanBoService tblCanBoService; 



    private List<TblQLDTTXAHocKyTrongNam> tblQLDTTXAHocKyTrongNams; 
    public List<TblQLDTTXAHocKyTrongNam>  getTblQLDTTXAHocKyTrongNams(){ 
              return tblQLDTTXAHocKyTrongNams; 
     } 

    private TblQLDTTXAHocKyTrongNamService tblQLDTTXAHocKyTrongNamService; 

    private List<TblQLDTTXAHocVienHocPhiMonHoc> tblQLDTTXAHocVienHocPhiMonHocs; 
    public List<TblQLDTTXAHocVienHocPhiMonHoc>  getTblQLDTTXAHocVienHocPhiMonHocs(){ 
              return tblQLDTTXAHocVienHocPhiMonHocs; 
     } 

    private TblQLDTTXAHocVienHocPhiMonHocService tblQLDTTXAHocVienHocPhiMonHocService; 

    private List<TblQLDTTXAHocVienHocPhi> tblQLDTTXAHocVienHocPhis; 
    public List<TblQLDTTXAHocVienHocPhi>  getTblQLDTTXAHocVienHocPhis(){ 
              return tblQLDTTXAHocVienHocPhis; 
     } 

    private TblQLDTTXAHocVienHocPhiService tblQLDTTXAHocVienHocPhiService; 

    private List<TblQLDTTXAMonHoc> tblQLDTTXAMonHocs; 
    public List<TblQLDTTXAMonHoc>  getTblQLDTTXAMonHocs(){ 
              return tblQLDTTXAMonHocs; 
     } 

    private List<TblQLDTTXADonXinGiaHanHPChiTiet> tblQLDTTXADonXinGiaHanHPChiTiets;
    private TblQLDTTXADonXinGiaHanHPChiTietService tblQLDTTXADonXinGiaHanHPChiTietService;

    private Long tuHocKyId;
  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
 public String execute() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_DonXinGiaHanHocPhi", "sua")){ 
        return "noprivilege"; 
    }        
    
    	tblQLDTTXADonXinGiaHanHocPhiService = (TblQLDTTXADonXinGiaHanHocPhiService) context.getBean("tbl_QLDTTXA_DonXinGiaHanHocPhiClient"); 
    	tblQLDTTXADonXinGiaHanHPChiTietService = (TblQLDTTXADonXinGiaHanHPChiTietService) context.getBean("tbl_QLDTTXA_DonXinGiaHanHP_ChiTietClient"); 
        
    	tblQLDTTXAHocVienService = (TblQLDTTXAHocVienService) context.getBean("tbl_QLDTTXA_HocVienClient"); 

        tblCanBoService = (TblCanBoService) context.getBean("tbl_CanBoClient"); 

        tblQLDTTXAHocKyTrongNamService = (TblQLDTTXAHocKyTrongNamService) context.getBean("tbl_QLDTTXA_HocKyTrongNamClient"); 

        tblQLDTTXAHocVienHocPhiMonHocService = (TblQLDTTXAHocVienHocPhiMonHocService) context.getBean("tbl_QLDTTXA_HocVienHocPhi_MonHocClient"); 

        tblQLDTTXAHocVienHocPhiService = (TblQLDTTXAHocVienHocPhiService) context.getBean("tbl_QLDTTXA_HocVien_HocPhiClient"); 

        
        tblQLDTTXADonXinGiaHanHocPhi = tblQLDTTXADonXinGiaHanHocPhiService.gettblQLDTTXADonXinGiaHanHocPhi(new Long(id)); 

        tblCanBos = tblCanBoService.findAlltblCanBo(0, 0);

        tblQLDTTXAHocKyTrongNams = tblQLDTTXAHocKyTrongNamService.findAlltblQLDTTXAHocKyTrongNam(20, 1);

   List<ConditionReport> cons = new ArrayList<ConditionReport>(); 

   
//   if(tblQLDTTXADonXinGiaHanHocPhi.getHocVienId() != null){
//	   	cons.clear();
//	   	if(true){
//	       	ConditionReport con = new ConditionReport(); 
//	           con.setCol("hocVienHocPhiId.hocVienId.id");
//	           con.setValue1(tblQLDTTXADonXinGiaHanHocPhi.getHocVienId().getId());
//	           con.setOperator("eq");
//	           cons.add(con);		 
//	   	}
//	   	if(tuHocKyId != null && !tuHocKyId.equals(new Long(0))){
//	       	ConditionReport con = new ConditionReport(); 
//	           con.setCol("hocVienHocPhiId.hocKyId.id");
//	           con.setValue1(tuHocKyId);
//	           con.setOperator("eq");
//	           cons.add(con);		 
//	   	}else{
//	   		ConditionReport con = new ConditionReport(); 
//	           con.setCol("hocVienHocPhiId.hocKyId.id");
//	           con.setValue1(tblQLDTTXADonXinGiaHanHocPhi.getTuHocKyId().getId());
//	           con.setOperator("eq");
//	           cons.add(con);	
//	   	}
//			if(true){
//	       	ConditionReport con = new ConditionReport(); 
//	           con.setCol("daDongHP");
//	           con.setValue1(false);
//	           con.setOperator("eq");
//	           cons.add(con);		 
//	   	}
//			if(true){
//	       	ConditionReport con = new ConditionReport(); 
//	           con.setCol("mienMon");
//	           con.setValue1(false);
//	           con.setOperator("eq");
//	           cons.add(con);		 
//	   	}
//	       tblQLDTTXAHocVienHocPhiMonHocs = tblQLDTTXAHocVienHocPhiMonHocService.findtblQLDTTXAHocVienHocPhiMonHocByCondition(cons, 0, 0);
//   }
   
   	cons.clear();
   	if(true){
       	ConditionReport con = new ConditionReport(); 
           con.setCol("donGiaHanId.id");
           con.setValue1(tblQLDTTXADonXinGiaHanHocPhi.getId());
           con.setOperator("eq");
           cons.add(con);		 
   	}
   	tblQLDTTXADonXinGiaHanHPChiTiets = tblQLDTTXADonXinGiaHanHPChiTietService.findtblQLDTTXADonXinGiaHanHPChiTietByCondition(cons, 0, 0);

   	return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi EditForm tbl_QLDTTXA_DonXinGiaHanHocPhi Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 }

public Long getTuHocKyId() {
	return tuHocKyId;
}

public void setTuHocKyId(Long tuHocKyId) {
	this.tuHocKyId = tuHocKyId;
}

public List<TblQLDTTXADonXinGiaHanHPChiTiet> getTblQLDTTXADonXinGiaHanHPChiTiets() {
	return tblQLDTTXADonXinGiaHanHPChiTiets;
}

public void setTblQLDTTXADonXinGiaHanHPChiTiets(
		List<TblQLDTTXADonXinGiaHanHPChiTiet> tblQLDTTXADonXinGiaHanHPChiTiets) {
	this.tblQLDTTXADonXinGiaHanHPChiTiets = tblQLDTTXADonXinGiaHanHPChiTiets;
} 
 } 
 
